package com.scpii.universal.pns.entity;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

import com.scpii.universal.constant.GenericConstants;
import com.scpii.universal.pns.dto.ActivitiesBodyDto;
import com.scpii.universal.pns.dto.AddressDto;

/**
 * Activities entity. @author MyEclipse Persistence Tools
 */

public class Activities implements java.io.Serializable {

	// Fields

	private Long id;
	private Long appId;
	private Long cateId;
	private String title;
	private String summary;
	private String body;
	private String thumbImage;
	private Date startTime;
	private Date endTime;
	private Date signupStartTime;
	private Date signupEndTime;
	private Long maxJoinUsers;
	private Long reviewCount;
	private Long commentCount;
	private Long favCount;
	private Date createDt;
	private Long createBy;
	private Date updateDt;
	private Long updateBy;
	private String address;
	private String organizers;
	private String status;
	private Long joinedCount;

	private AddressDto addressDto;

	//
	List<ActivitiesBodyDto> bodyList;

	public void msgBodyToList() {
		JSONArray ja = JSONArray.fromObject(body);
		ActivitiesBodyDto bodyDto = null;
		JSONObject jo = null;
		if (bodyList == null)
			bodyList = new ArrayList<ActivitiesBodyDto>();
		int size = ja.size();
		for (int i = 0; i < size; i++) {
			bodyDto = new ActivitiesBodyDto();
			jo = JSONObject.fromObject(ja.get(i));
			bodyDto.setType(jo.getString("type"));
			if (jo.getString("type").equals(GenericConstants.TYPE_PHONE)) {
				bodyDto.setValue(jo.getString("title") + ":"
						+ jo.getString("value"));
			} else {
				bodyDto.setValue(jo.getString("value"));
			}

			bodyList.add(bodyDto);
		}

		JSONObject json = JSONObject.fromObject(address);
		addressDto = new AddressDto();
		addressDto.setFormattedAddress(json.getString("formattedAddress"));
		addressDto.setLongitude(json.getString("longitude"));
		addressDto.setLatitude(json.getString("latitude"));
	}

	// Constructors

	/** default constructor */
	public Activities() {
	}

	/** minimal constructor */
	public Activities(Long appId, Long cateId, String title, String body,
			Date startTime, Date endTime, Date signupStartTime,
			Date signupEndTime, Long maxJoinUsers, Long reviewCount,
			Long commentCount, Long favCount) {
		this.appId = appId;
		this.cateId = cateId;
		this.title = title;
		this.body = body;
		this.startTime = startTime;
		this.endTime = endTime;
		this.signupStartTime = signupStartTime;
		this.signupEndTime = signupEndTime;
		this.maxJoinUsers = maxJoinUsers;
		this.reviewCount = reviewCount;
		this.commentCount = commentCount;
		this.favCount = favCount;
	}

	/** full constructor */
	public Activities(Long appId, Long cateId, String title, String summary,
			String body, String thumbImage, Date startTime, Date endTime,
			Date signupStartTime, Date signupEndTime, Long maxJoinUsers,
			Long reviewCount, Long commentCount, Long favCount, Date createDt,
			Long createBy, Date updateDt, Long updateBy, String address,
			String organizers, String status, Long joinedCount) {
		this.appId = appId;
		this.cateId = cateId;
		this.title = title;
		this.summary = summary;
		this.body = body;
		this.thumbImage = thumbImage;
		this.startTime = startTime;
		this.endTime = endTime;
		this.signupStartTime = signupStartTime;
		this.signupEndTime = signupEndTime;
		this.maxJoinUsers = maxJoinUsers;
		this.reviewCount = reviewCount;
		this.commentCount = commentCount;
		this.favCount = favCount;
		this.createDt = createDt;
		this.createBy = createBy;
		this.updateDt = updateDt;
		this.updateBy = updateBy;
		this.address = address;
		this.organizers = organizers;
		this.status = status;
		this.joinedCount = joinedCount;
	}

	// Property accessors

	public Long getId() {
		return this.id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public Long getAppId() {
		return this.appId;
	}

	public void setAppId(Long appId) {
		this.appId = appId;
	}

	public Long getCateId() {
		return this.cateId;
	}

	public void setCateId(Long cateId) {
		this.cateId = cateId;
	}

	public String getTitle() {
		return this.title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getSummary() {
		return this.summary;
	}

	public void setSummary(String summary) {
		this.summary = summary;
	}

	public String getBody() {
		return this.body;
	}

	public void setBody(String body) {
		this.body = body;
	}

	public String getThumbImage() {
		return this.thumbImage;
	}

	public void setThumbImage(String thumbImage) {
		this.thumbImage = thumbImage;
	}

	public Date getStartTime() {
		return startTime;
	}

	public void setStartTime(Date startTime) {
		this.startTime = startTime;
	}

	public Date getEndTime() {
		return endTime;
	}

	public void setEndTime(Date endTime) {
		this.endTime = endTime;
	}

	public Date getSignupStartTime() {
		return signupStartTime;
	}

	public void setSignupStartTime(Date signupStartTime) {
		this.signupStartTime = signupStartTime;
	}

	public Date getSignupEndTime() {
		return signupEndTime;
	}

	public void setSignupEndTime(Date signupEndTime) {
		this.signupEndTime = signupEndTime;
	}

	public Long getMaxJoinUsers() {
		return this.maxJoinUsers;
	}

	public void setMaxJoinUsers(Long maxJoinUsers) {
		this.maxJoinUsers = maxJoinUsers;
	}

	public Long getReviewCount() {
		return this.reviewCount;
	}

	public void setReviewCount(Long reviewCount) {
		this.reviewCount = reviewCount;
	}

	public Long getCommentCount() {
		return this.commentCount;
	}

	public void setCommentCount(Long commentCount) {
		this.commentCount = commentCount;
	}

	public Long getFavCount() {
		return this.favCount;
	}

	public void setFavCount(Long favCount) {
		this.favCount = favCount;
	}

	public Date getCreateDt() {
		return this.createDt;
	}

	public void setCreateDt(Date createDt) {
		this.createDt = createDt;
	}

	public Long getCreateBy() {
		return this.createBy;
	}

	public void setCreateBy(Long createBy) {
		this.createBy = createBy;
	}

	public Date getUpdateDt() {
		return this.updateDt;
	}

	public void setUpdateDt(Date updateDt) {
		this.updateDt = updateDt;
	}

	public Long getUpdateBy() {
		return this.updateBy;
	}

	public void setUpdateBy(Long updateBy) {
		this.updateBy = updateBy;
	}

	public String getAddress() {
		return this.address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public String getOrganizers() {
		return this.organizers;
	}

	public void setOrganizers(String organizers) {
		this.organizers = organizers;
	}

	public String getStatus() {
		return this.status;
	}

	public void setStatus(String status) {
		this.status = status;
	}

	public Long getJoinedCount() {
		return this.joinedCount;
	}

	public void setJoinedCount(Long joinedCount) {
		this.joinedCount = joinedCount;
	}

	public List<ActivitiesBodyDto> getBodyList() {
		return bodyList;
	}

	public void setBodyList(List<ActivitiesBodyDto> bodyList) {
		this.bodyList = bodyList;
	}

	public AddressDto getAddressDto() {
		return addressDto;
	}

	public void setAddressDto(AddressDto addressDto) {
		this.addressDto = addressDto;
	}

}